<template>
	<view class="page">
		<view class="bar_info" :style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx'}">
			<view class="title_bar">
				<view class="title_bar_left" @tap.stop="isBack">
					<u-icon size="38" name="arrow-left"></u-icon>
				</view>
				<view class="title_bar_center">
					设置
				</view>
				<view class="title_bar_right"></view>
			</view>
		</view>
		<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
		<view class="set_content">
			<view class="set_list">
				<view class="list_item" @tap.stop="bindWithdrawal">
					<view class="list_item_left">绑定提现账号</view>
					<view class="list_item_right">
						<u-icon name="arrow-right" color="#ccc" size="30"></u-icon>
					</view>
				</view>
				<view class="list_item" @tap.stop="loginPsd">
					<view class="list_item_left">修改登录密码</view>
					<view class="list_item_right">
						<u-icon name="arrow-right" color="#ccc" size="30"></u-icon>
					</view>
				</view>
				<view class="list_item no_border" @tap.stop="payPsd">
					<view class="list_item_left" v-if="is_pay == 0">设置提现密码</view>
					<view class="list_item_left" v-else>修改提现密码</view>
					<view class="list_item_right">
						<u-icon name="arrow-right" color="#ccc" size="30"></u-icon>
					</view>
				</view>
			</view>
			<view class="set_list">
				<view class="list_item" @tap.stop="handleAgreement(1)">
					<view class="list_item_left">隐私政策</view>
					<view class="list_item_right">
						<u-icon name="arrow-right" color="#ccc" size="30"></u-icon>
					</view>
				</view>
				<view class="list_item no_border" @tap.stop="handleAgreement(2)">
					<view class="list_item_left">用户协议</view>
					<view class="list_item_right">
						<u-icon name="arrow-right" color="#ccc" size="30"></u-icon>
					</view>
				</view>
			</view>
			<view class="set_list">
				<view class="list_item" @tap.stop="loginOut(1)">
					<view class="list_item_left">注销账号</view>
					<view class="list_item_right">
						<u-icon name="arrow-right" color="#ccc" size="30"></u-icon>
					</view>
				</view>
				<view class="list_item no_border" @tap.stop="loginOut(2)">
					<view class="list_item_left">退出登录</view>
					<view class="list_item_right">
						<u-icon name="arrow-right" color="#ccc" size="30"></u-icon>
					</view>
				</view>
			</view>
		</view>
		
		<u-modal v-model="show" :content="content" :show-cancel-button="true" confirm-color="#0278FC" @confirm="confirm"></u-modal>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				show: false,
				content: "",
				is_pay: 0,  // 0未设置   1已设置
				confirm_type: 1
			}
		},
		onLoad() {
			
		},
		onShow() {
			this.checkPay();
		},
		methods: {
			// 检测是否设置支付密码  postCheckPayPsd
			checkPay() {
				this.$api.post(global.apiUrls.postCheckPayPsd, {
					
				}).then(res => {
					// console.log(res);
					if (res.data.code == 1) {
						this.is_pay = res.data.data.is_pay;
					} else {
						this.$message.info(res.data.msg);
					}
				})
			},
			
			bindWithdrawal() {
				uni.navigateTo({
					url: '/pages/my/withdrawal'
				})
			},
			loginPsd() {
				uni.navigateTo({
					url: '/pages/my/changeLoginPsd'
				})
			},
			payPsd() {
				uni.navigateTo({
					url: '/pages/my/changePayPsd?is_pay=' + this.is_pay
				})
			},
			handleAgreement(type) {
				uni.navigateTo({
					url: '/pages/login/agreement?type=' + type
				})
			},
			loginOut(type) {
				this.confirm_type = type;
				if (type == 1) {
					this.content = '确定要注销账号吗？'
				} else if (type == 2) {
					this.content = '确定要退出登录吗？'
				}
				this.show = true;
			},
			confirm() {
				this.show = false;
				if (this.confirm_type == 1) {
					this.$message.info('已提交，等待平台审核');
					return;
				} else if (this.confirm_type == 2) {
					this.$store.commit('logout');
					uni.redirectTo({
						url: '/pages/login/login'
					})
				}
			},
			isBack() {
				uni.navigateBack();
			}
		}
	}
</script>

<style lang="scss" scoped>
	.page {
		.bar_info {
			width: 750rpx;
			height: 88rpx;
			overflow: hidden;
			z-index: 10;
			position: fixed;
			top: 0rpx;
		
			.title_bar {
				padding: 0 32rpx;
				display: flex;
				justify-content: space-between;
				align-items: center;
		
				.title_bar_left {
					width: 50rpx;
				}
		
				.title_bar_center {
					line-height: 88rpx;
					font-size: 36rpx;
					font-weight: 400;
				}
		
				.title_bar_right {
					width: 50rpx;
				}
			}
		}
		.set_content {
			padding: 30rpx;
			.set_list {
				background: #fff;
				border-radius: 20rpx;
				padding: 0 30rpx;
				margin-bottom: 24rpx;
				.list_item {
					display: flex;
					align-items: center;
					justify-content: space-between;
					padding: 40rpx 0;
					border-bottom: 1rpx solid #eee;
					.list_item_left {
						font-size: 30rpx;
					}
				}
				.no_border {
					border-bottom: 1rpx solid transparent;
				}
			}
		}
	}
</style>